package com.example.trafficsystem.service;

import com.example.trafficsystem.entity.Task;
import com.example.trafficsystem.entity.TrainingDocument;
import com.example.trafficsystem.entity.TrainingPlan;
import com.example.trafficsystem.repository.TaskRe;
import com.example.trafficsystem.repository.TrainingPlanRe;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

@Service
public class TrainingPlanService {
    @Autowired
    private TrainingPlanRe trainingPlanRepository;
    @Autowired
    private TaskRe taskRepository;

    public List<TrainingPlan> getAllTrainingPlans(Long organizationId) {
        return trainingPlanRepository.findByOrganizationId(organizationId);
    }
    //获取培训计划中的任务点
    public Set<TrainingDocument>getTrainingDocuments(Long trainingPlanId){
        TrainingPlan trainingPlan = trainingPlanRepository.findById(trainingPlanId)
                .orElseThrow(()-> new RuntimeException("培训计划不存在"));
        return trainingPlan.getDocuments();
    }
    // 计算某个培训计划的完成进度

}
